package day1.zy2;

import java.util.Objects;

public class Yuangong implements Comparable<Yuangong>{

   private String name;
   private int age;
   private String sex;
   private String zhiwu;
   private int xinshui;
   private String gonghao;

    public Yuangong() {
    }

    public Yuangong(String name, int age, String sex, String zhiwu, int xinshui, String gonghao) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.zhiwu = zhiwu;
        this.xinshui = xinshui;
        this.gonghao = gonghao;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getZhiwu() {
        return zhiwu;
    }

    public void setZhiwu(String zhiwu) {
        this.zhiwu = zhiwu;
    }

    public int getXinshui() {
        return xinshui;
    }

    public void setXinshui(int xinshui) {
        this.xinshui = xinshui;
    }

    public String getGonghao() {
        return gonghao;
    }

    public void setGonghao(String gonghao) {
        this.gonghao = gonghao;
    }

    @Override
    public String toString() {
        return "Yuangong{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", zhiwu='" + zhiwu + '\'' +
                ", xinshui=" + xinshui +
                ", gonghao='" + gonghao + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Yuangong yuangong = (Yuangong) o;
        return age == yuangong.age;
    }

    @Override
    public int hashCode() {
        return Objects.hash(age);
    }

    public void show(){

    }


    @Override
    public int compareTo(Yuangong o) {
        if (this.getAge()==o.getAge()){
            return 0;
        }else if (this.getAge()>o.getAge()){
            return 1;
        }
        return -1;
    }
}


